package com.jprocms.module.cms.controller.admin.content.vo;

import com.jprocms.module.cms.query.WhereCondition;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.lang.Nullable;

import java.sql.Date;
import java.time.OffsetDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Schema(description = "内容分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ContentFrontQueryReqVO extends ContentPageReqVO {

    //前台查询默认查询，后台默认不查询
    @Schema(description = "是否查询引用栏目")
    private Boolean querySubChannel = true;
    /**
     * 标记属性
     */
    @Schema(description = "标记属性")
    private Collection<Long> dictMarks;
    /**
     * 区块ID
     */
    @Schema(description = "区块")
    private Collection<Long> dictBlocks;

    @Schema(description = "排除内容id")
    private Collection<Long> excludeIds;

    @Schema(description = "排除标记属性")
    private Collection<Long> excludeDictMarks;
    /**
     * 区块ID
     */
    @Schema(description = "排除区块")
    private Collection<Long> excludeDictBlocks;

    /**
     * tagId
     */
    @Schema(description = "tagId")
    private Collection<Long> tagIds;


    @Schema(description = "查询结果开始下标")
    private Integer offset = 0;

    @Schema(description = "取多少条")
    private Integer count = 0;

    @Schema(description = "是否所有站点")
    private Boolean allSite = false;

    @Schema(description = "是否包含子栏目")
    private Boolean includeChildChannel = true;

    @Schema(description = "栏目路径")
    private Collection<String> channelPaths;

    @Schema(description = "最大分页数量")
    public Integer pageMax;

    //自定义字段查询（DB查询用）
    @Nullable
    private List<WhereCondition> customsConditions;

    //自定义字段查询（ES查询用）
    @Nullable
    private Map<String, Object> customs;

    @Schema(description = "排序")
    private Integer orderBy;

    public ContentFrontQueryReqVO toSetPublishBeginDate(@Nullable OffsetDateTime begin) {
        if (begin != null) {
            setReleaseTimeStart(Date.from(begin.toInstant()));
        }
        return this;
    }

    public ContentFrontQueryReqVO toSetPublishEndDate(@Nullable OffsetDateTime end) {
        if (end != null) {
            setReleaseTimeEnd(Date.from(end.toInstant()));
        }
        return this;
    }


}
